package com.oromwin.repos.server.response.media;

import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;

import org.apache.commons.logging.Log;

import com.oromwin.repos.common.Logger;
import com.oromwin.repos.common.ReposException;
import com.oromwin.repos.common.helper.IOHelper;
import com.oromwin.repos.data.MediaTable;
import com.oromwin.repos.server.response.NormalResponse;

public class InfoMediaResponse extends NormalResponse {
    private Log log = Logger.getLog(InfoMediaResponse.class);
    private MediaTable mediaTable = null;
    
    public InfoMediaResponse() {
    }
    
    public void receive(DataInputStream dis) throws ReposException {
        try {
            Result = dis.readBoolean();
            Description = IOHelper.readUTF8(dis);
            String volumeId = IOHelper.readUTF8(dis);
            String mediaId = IOHelper.readUTF8(dis);
            File mediaPath = new File(IOHelper.readUTF8(dis));
            Long mediaMaxBytes = new Long(dis.readLong());
            Long mediaUsedBytes = new Long(dis.readLong());
            Integer mediaFileCount = new Integer(dis.readInt());
            Boolean mediaStatus = new Boolean(dis.readBoolean());
            String mediaCreateDate = IOHelper.readUTF8(dis);
            String mediaUpdateDate = IOHelper.readUTF8(dis);
            mediaTable = new MediaTable(volumeId, mediaId, mediaPath, mediaMaxBytes, mediaUsedBytes, mediaFileCount, mediaStatus, mediaCreateDate, mediaUpdateDate);
        } catch (IOException e) {
            throw ReposException.create(log, e);
        }
    }
    public MediaTable getMediaTable() {
        return mediaTable;
    }
}
